
CPP  = g++.exe
CC   = gcc.exe
AS   = as.exe
WINDRES = windres.exe
DLLWRAP = dllwrap.exe
RES = 
OBJ  = lilithapi.o cpuclock.o  $(RES)
LINKOBJ = lilithapi.o cpuclock.o  $(RES) 
LIBS =  -L"C:/MinGW32/lib"
CINCS =  -I"C:/MinGW32/include"
CXXINCS =  -I"C:/MinGW32/include"
OUTPUT_NAME = lilithapi
BIN  = lilithapi.dll
CXXFLAGS =  -Wall $(CPPINCS)
CFLAGS =  -Wall $(CINCS)
ASFLAGS = 

RM = rm -f 

.PHONY: all all-before all-after clean clean-custom

all: all-before $(BIN) all-after


clean: clean-custom
	${RM} $(OBJ) $(BIN)


DEFFILE = $(OUTPUT_NAME).def
STATICLIB = $(OUTPUT_NAME).a
$(BIN): $(OBJ)
	$(DLLWRAP) --output-def $(DEFFILE) --driver-name c++ --implib $(STATICLIB) $(LINKOBJ) $(LIBS) -o $(BIN)


lilithapi.o: lilithapi.c cpuclock.h

	$(CC) -c $< -o $@ $(CFLAGS) 


cpuclock.o: cpuclock.c cpuclock.h

	$(CC) -c $< -o $@ $(CFLAGS) 


%.res: %.rc
	$(WINDRES) $< -O coff -o $@
	
	
%.o: %.cpp
	$(CPP) -c $< -o $@ $(CXXFLAGS)
%.o: %.cc
	$(CPP) -c $< -o $@ $(CXXFLAGS)
%.o: %.cp
	$(CPP) -c $< -o $@ $(CXXFLAGS)
%.o: %.cxx
	$(CPP) -c $< -o $@ $(CXXFLAGS)
%.o: %.c++
	$(CPP) -c $< -o $@ $(CXXFLAGS)
%.o: %.C
	$(CPP) -c $< -o $@ $(CXXFLAGS)
	

%.o: %.c
	$(CC) -c $< -o $@ $(CFLAGS)

%.o: %.s
	$(AS) $< $(ASFLAGS)
	
%.s: %.S
	$(CC) -E $< -o $@ $(CFLAGS)
%.s: %.sx
	$(CC) -E $< -o $@ $(CFLAGS)
	

%.s: %.c
	$(CC) -S $< -o $@ $(CFLAGS)
	
%.s: %.cpp
	$(CPP) -S $< -o $@ $(CXXFLAGS)

%.i: %.c
	$(CC) -E $< -o $@ $(CFLAGS)

%.ii: %.cpp
	$(CPP) -E $< -o $@ $(CXXFLAGS)
